package novel.spider.util;

import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpGet;

import java.net.URI;

/**
 * Created by Kau on 2016/11/1.
 */
public final class NovelSpiderHttpGet extends HttpGet {
    public NovelSpiderHttpGet() {
        super();
    }

    public NovelSpiderHttpGet(URI uri) {
        super(uri);
    }

    public NovelSpiderHttpGet(String uri) {
        super(uri);
        setDefaultConfig();
    }

    /**
     * 设置默认请求参数
     */
    private void setDefaultConfig(){
        this.setConfig(RequestConfig.custom()
                .setSocketTimeout(2_000)    // 这只Socket超时时间
                .setConnectTimeout(10_000)  // 设置连接服务器超时时间
                .setConnectionRequestTimeout(10_000) //设置从服务器接收数据超时时间
                .build());
    }

}
